package com.hhit.zhgd.service

import com.baomidou.mybatisplus.extension.plugins.pagination.Page
import com.hhit.zhgd.domain.entity.ErrorLog
import org.junit.jupiter.api.Test

import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest

@SpringBootTest
internal class ErrorLogServiceTest {
    @Autowired
    private var errorLogService: ErrorLogService? = null

    @Test
    fun save() {
        errorLogService?.save(
            url = "http://test.com",
            method = "GET",
            params = "{}",
            exception = "test",
            message = "test"
        )
    }

    @Test
    fun getList() {
        val page = Page<ErrorLog>(1, 10)
        val params = HashMap<String, Any?>()
        params["start"] = "2023-09-22"
        params["end"] = "2023-10-17"
        val list = errorLogService?.getList(page, params)
        list?.let {
            for (item in it.records) {
                println("${item["message"]}")
//                println("${item["id"]},${item["url"]},${item["method"]},${item["params"]},${item["message"]},${item["exception"]}")
            }
        }
    }
}